home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d10
/
pros15.arc
/
PROS15.EXE
/
PROCVSPD.C
< prev
next >
Wrap
Text File
|
1991-04-07
|
4KB
|
141 lines
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Filename : PROCVSPD.C *
* Version : 1.2 *
* Project : PRO$TOCK: Download Stock Quotes from Prodigy *
* Author : Philippe Rabergeau *
* Copyright : (C) 1990 by Philippe Rabergeau *
* Compiler : Borland Turbo C++ Version 1.0 Large model/Byte align*
* Creation date : 06/28/90 *
* Modification date : 11/04/90 *
* Description : Conversion of Prodigy Stock Quotes format *
* Comments : Not for Commercial Use *
* *
* SPD like Spreadsheet format *
* *
* PRO$TOCK registered users, freeware and shareware authors are allowed *
* to modify and incorporate this source code in any type of program. *
* Please inform the author of any development in association *
* with this source code: Philippe Rabergeau *
* 512 E. 5th St. #9 *
* New York, NY 10009 *
* Prodigy ID WNWB44A *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
char extract_str[7][20];
double extract_val[7];
/***********************************************************/
/* Change only this part for other format */
/***********************************************************/
int result_start(FILE *out) /* put header here */
{
return(1);
}
int result_end(FILE *out)
{
return(1);
}
int result_save(FILE *out)
{
int i;
for(i=0;i<2;i++) fprintf(out,"\"%s\",",extract_str[i]);
for(;i<5;i++) fprintf(out,"%s,",extract_str[i]);
if ((strchr(extract_str[5],'/')!=NULL)||(extract_str[5][0]==0))
fprintf(out,"\"%s\"",extract_str[5]);
else fprintf(out,"%s",extract_str[5]);
fprintf(out,"\r\n");
return(1);
}
/***********************************************************/
int convert(FILE *in,FILE *out)
{
int i;
char s[90];
result_start(out);
fgets(s,83,in);
fgets(s,83,in);
fgets(s,83,in);
fgets(s,83,in);
fgets(s,83,in);
while(fgets(s,83,in)!=NULL)
{
s[strlen(s)-1]=0;
if ((s[0]>' ')&&(s[0]!='-'))
{
for(i=0;i<6;i++) extract_str[i][0]=0;
sscanf(s,"%s %s %s %s %s %s",extract_str[0],extract_str[1],extract_str[2]
,extract_str[3],extract_str[4],extract_str[5]);
for(i=2;i<6;i++) extract_val[i]=atof(extract_str[i]);
result_save(out);
}
else break;
}
result_end(out);
return(1);
}
/*--- Main program ---*/
void main(int argc, char *argv[])
{
int ret=1;
char fname_in[64];
char fname_out[64];
FILE *fp_in;
FILE *fp_out;
clrscr();
/*--- definition of input and output filename ---*/
if (argc<2) strcpy(fname_in,"PRODIGY.ASC");
else strcpy(fname_in,argv[1]);
if (argc<3) strcpy(fname_out,"PRODIGY.SPD");
else
{
strcpy(fname_out,argv[2]);
if (fname_out[strlen(fname_out)-1]=='\\') strcat(fname_out,"PRODIGY.SPD");
else if (fname_out[strlen(fname_out)-1]=='.') strcat(fname_out,"SPD");
}
/*--- conversion of filename in upper case ---*/
strupr(fname_in);
strupr(fname_out);
printf("Convert Prodigy Stock Quotes into Spreadsheet format\n\n");
printf("Converting the file '%s'\n",fname_in);
printf("Result saved into '%s'\n",fname_out);
/*--- Open files ---*/
if ((fp_in=fopen(fname_in,"rt"))==NULL)
{
printf("ERROR: Can't open input file '%s'\n",fname_in);
ret=0;
}
else
{
if ((fp_out=fopen(fname_out,"w+b"))==NULL)
{
printf("ERROR: Can't creat output file '%s'\n",fname_out);
ret=0;
}
else
{
/*--- Conversion in progress ---*/
convert(fp_in,fp_out);
fclose(fp_out);
}
fclose(fp_in);
}
exit(ret);
}